import request from '@/utils/request'

export function goodsCate(query) {
  return request({
    url: '/category/manager/list',
    method: 'get',
    params: query
  })
}
export function addGoodsCate(data) {
  return request({
    url: '/category/manager/addCategory',
    method: 'post',
    data
  })
}
export function editGoodsCate(data) {
  return request({
    url: `/category/manager/updateCategory`,
    method: 'put',
    data
  })
}

export function editGoodsIsShowCate(state,id,data) {
  return request({
    url: `/category/manager/updateCategory/${state}/${id}`,
    method: 'put',
    data
  })
}
export function deleteGoodsCate(id) {
  return request({
    url: `/category/manager/deleteCategory/${id}`,
    method: 'delete'
  })
}

// 获取所有商品分类
export function allCate(query) {
  return request({
    url: '/category/manager/getAllCategory',
    method: 'get',
    params: query
  })
}

// 获取商品列表
export function queryGoodsList(query) {
  return request({
    url: '/goods/manage/queryGoodsList',
    method: 'get',
    params: query
  })
}

// 发布商品
export function addGoods(data) {
  return request({
    url: '/goods/manage/addGoods',
    method: 'post',
    data
  })
}

//删除商品
export function deleteGoods(goodsId) {
  return request({
    url: `/goods/manage/deleteGoods/${goodsId}`,
    method: 'delete'
  })
}


// 获取商品详情
export function queryGoodsDetails(id) {
  return request({
    url: `goods/manage/detail/${id}`,
    method: 'get'
  })
}

// 更新商品
export function updateGoods(data) {
  return request({
    url: '/goods/manage/updateGoods',
    method: 'put',
    data
  })
}

// 商品上下架
export function updateGoodsDown(data,goodsId) {
  return request({
    url: `/goods/manage/updateSaleFlag/${goodsId}`,
    method: 'put',
    data
  })
}
